package com.ruoyi.matrix.task.other

import com.ruoyi.common.utils.ip.IpUtils
import com.ruoyi.matrix.queue.FatmoreLock
import org.springframework.scheduling.annotation.Scheduled
import org.springframework.stereotype.Service
import java.time.Duration

// 保持redis/mysql活跃
@Service
class KeepAlive(
    private val fatmoreLock: FatmoreLock,
//    private val rechargeService: RechargeService,
) {
    // 每10秒一次保活
    @Scheduled(cron = "*/10 * * * * *")
    fun doit() {
        if(!IpUtils.isPro()) {
            fatmoreLock.lock( "__keepalive__", ".", Duration.ofSeconds(9).toMillis())
//            rechargeService.getById(0L)
        }
    }
}